//
//  TBCRadioTableViewCell.m
//  待定
//
//  Created by EricXie on 15/11/5.
//  Copyright © 2015年 BoyaLee. All rights reserved.
//

#import "TBCRadioTableViewCell.h"

@implementation TBCRadioTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createSubViews];
    }
    
    return self;
}

- (void)createSubViews
{
    self.headerImageV = [[UIImageView alloc] initWithFrame:CGRectMake(HEIGHT * 0.015, HEIGHT * 0.015, HEIGHT * 0.12, HEIGHT * 0.12)];
    self.headerImageV.backgroundColor = [UIColor lightGrayColor];
    _headerImageV.layer.masksToBounds = YES;
    _headerImageV.layer.cornerRadius = 15;
    [self addSubview:_headerImageV];
    
    self.titleLabel = [[BaseLabel alloc] initWithFrame:CGRectMake(_headerImageV.frame.size.width + _headerImageV.frame.origin.x + WIDTH * 0.015, _headerImageV.frame.origin.y + HEIGHT * 0.015, WIDTH * 0.3, self.frame.size.height * 0.3)];
    _titleLabel.font = [UIFont systemFontOfSize:19 * SIZE];
    [self addSubview:_titleLabel];
    
    self.listenLabel = [[BaseLabel alloc] initWithFrame:CGRectMake(WIDTH * 0.7, _titleLabel.frame.origin.y, WIDTH * 0.28, _titleLabel.frame.size.height)];
    _listenLabel.textColor = [UIColor lightGrayColor];
    _listenLabel.font = [UIFont systemFontOfSize:15 * SIZE];
    _listenLabel.textAlignment = NSTextAlignmentRight;
    [self addSubview:_listenLabel];
    
    self.byLabel = [[BaseLabel alloc] initWithFrame:CGRectMake(_titleLabel.frame.origin.x, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + HEIGHT * 0.02, _titleLabel.frame.size.width,_titleLabel.frame.size.height)];
    _byLabel.textColor = [UIColor lightGrayColor];
    _byLabel.font = [UIFont systemFontOfSize:15 * SIZE];
    [self addSubview:_byLabel];
    
    self.detailLabel = [[BaseLabel alloc] initWithFrame:CGRectMake(_byLabel.frame.origin.x, _byLabel.frame.origin.y + _byLabel.frame.size.height + HEIGHT * 0.02, WIDTH * 0.7, _titleLabel.frame.size.height)];
    _detailLabel.textColor = [UIColor lightGrayColor];
    _detailLabel.font = [UIFont systemFontOfSize:18 * SIZE];
    _detailLabel.numberOfLines = 2;
    _detailLabel.lineBreakMode = NSLineBreakByWordWrapping;
    [self addSubview:_detailLabel];
    
    self.isNewImageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"iconfont-tubiao103"]];
    _isNewImageV.frame = CGRectMake(_headerImageV.frame.origin.x, _headerImageV.frame.origin.y, WIDTH * 0.1, WIDTH * 0.1);
    [self addSubview:_isNewImageV];
}

- (void)setRadioListModel:(TBCRadioListModel *)radioListModel
{
    [_headerImageV sd_setImageWithURL:[NSURL URLWithString:radioListModel.coverimg]];
    _titleLabel.text = radioListModel.title;
    _listenLabel.text = [NSString stringWithFormat:@"%ld", radioListModel.count];
    _byLabel.text = [NSString stringWithFormat:@"by:%@", radioListModel.userModel.uname];
    _detailLabel.text = radioListModel.desc;
    if (!radioListModel.isnew) {
        _isNewImageV.hidden = YES;
    } else {
        _isNewImageV.hidden = NO;
    }
}

@end
